<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="UTF-8">
		<link rel="stylesheet" href="editormd/css/editormd.css" />
		<title></title>
        <style type="text/css">
            #nameInp{
                height: 55px;
                border: none;
                font-size: 36px;
                width: 1046px;
                margin-left: 20px;
            }
            form{
                background-color: #FFF;
            }

            #save{
                width: 80px;
                height: 36px;
                border: 1px solid #E2E2E2;
                border-radius: 8px;
                background-color: #fff;
                position: absolute;
                top: 9px;

            }
            #save:hover{
                border: 1px solid #959FB0;
            }
            #eTimages{
                position: absolute;
                margin-left: 100px;
                top: 16px;
            }
            #eTimages img{
                width: 22px;
                height: 22px;
                margin-right: 6px;

            }
        </style>
	</head>

	<body>
        <div id="eTop" style="height: 55px; position: relative;">
            <input id="nameInp"/>
            <input type="button" value="保存" id="save" />
            <span id="eTimages">
                            <img src="img/tra1.png" style="width: 20px; height: 20px;" onMouseOver="this.src='img/tra2.png'" onMouseOut="this.src='img/tra1.png'"/>
                            <img src="img/share3.png" onMouseOver="this.src='img/share4.png'" onMouseOut="this.src='img/share3.png'"/>
                            <img src="img/rad1.png" style="width: 24px; height: 24px;" onMouseOver="this.src='img/rad2.png'" onMouseOut="this.src='img/rad1.png'"/>
                            <img src="img/note1.png" style="margin-right: 10px; width: 21px; height: 21px;" onMouseOver="this.src='img/note2.png'" onMouseOut="this.src='img/note1.png'"/>
                            <img src="img/more3.png"  style="margin-right: 10px;" onMouseOver="this.src='img/more4.png'" onMouseOut="this.src='img/more3.png'"/>
                            <img src="img/more1.png" style="width: 18px; height: 18px;" onMouseOver="this.src='img/more2.png'" onMouseOut="this.src='img/more1.png'"/>
                        </span>


        </div>
		<div id="test-editor" style="height: 100%;" >
			<!--{{info.content}}-->
			<textarea id="markdown"  style="display:none;" ></textarea>
			<!--<textarea class="editormd-markdown-textarea" name="$id-markdown-doc"></textarea>
			&lt;!&ndash; html textarea 需要开启配置项 saveHTMLToTextarea == true &ndash;&gt;
			<textarea class="editormd-html-textarea" name="$id-html-code"></textarea>-->
		</div>
		<button onclick="get()">qwedwq</button>
		<script src="https://cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
		<script src="editormd/editormd.min.js"></script>
		<script type="text/javascript">

			/*new Vue({
				el: '#test-editor',
				data() {
					return {
						content: "无内容"
					}
				},
				mounted() {
					var _this = this;

					axios.get('http://338de254.cpolar.io/note-notes/notes/searchNote',{
						params: {
							id:sessionStorage.getItem("nId"),
							token:sessionStorage.getItem("accessToken"),
						}
					})
							// .then(response => (this.content = response.data.content))
							.then(function (response) {
								console.log(response);
								_this.content = response.data.content;
								console.log(_this.content);
							})
							.catch(function (error) { // 请求失败处理
								console.log(error);
							});
				}
			})*/

			$(function() {
				var editor = editormd("test-editor", {
					 width  : "100%",
					 height : "100%",
					 emoji : true ,
					path: "editormd/lib/"
				});

               //查询内容
                $.ajax({
                    data:{
                        id:sessionStorage.getItem("nId"),
						token:sessionStorage.getItem("accessToken"),
                    },
                    url:'http://338de254.cpolar.io/note-notes/notes/searchNote',
                    success:function (data) {
                        $('#nameInp').val(data.notesName);
                            console.log(data.content);
					/*	$('#test-editor .editormd-markdown-textarea').val(data.content);
						$('#test-editor .editormd-html-textarea').val(data.content);*/
						$('#markdown').val(data.content);
						/*$(".CodeMirror-sizer").text(data.content);*/
                    }
                })
			});

			//修改编辑
            layui.use(['element', 'layer'], function () {
                var element = layui.element;
                var $ = layui.$;
                var layer = layui.layer;
                var label = $("#label");

                $('#save').click(function () {
                    $.ajax({
                        data:{
                            id:sessionStorage.getItem("nId"),
                            content:$('.editormd-markdown-textarea').val(),
							token:sessionStorage.getItem("accessToken"),
                        },
                        url:'http://338de254.cpolar.io/note-notes/notes/updateContent',
                        success:function (d) {
                            if (d.rs) {
                                parent.layer.msg('添加成功', {icon: 1});
                                window.location.reload();
                            }

                        }
                    });
                })


            });

		function get(){
			alert("111"+$('#markdown').val());
		}


		</script>

	</body>

</html>